package com.gxuwz.restaurant.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gxuwz.restaurant.common.Result;
import com.gxuwz.restaurant.entity.Cart;
import com.gxuwz.restaurant.entity.Order;
import com.gxuwz.restaurant.entity.User;
import com.gxuwz.restaurant.mapper.CartMapper;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/detail")
public class Order_detailController {

    @Resource
    CartMapper cartMapper;

    @GetMapping("/getDetail_Order")   //get用来查询
    public Result<?> findPageDetail_Order(@RequestParam(defaultValue = "1") Integer pageNum,
                              @RequestParam(defaultValue = "10") Integer pageSize,
                              @RequestParam(defaultValue = "") String category,
                              @RequestParam(defaultValue = "") String orderNo

    ) {

        LambdaQueryWrapper<Cart> wrapper = Wrappers.<Cart>lambdaQuery();
        wrapper.eq(Cart::getOrderNo,orderNo);
        wrapper.eq(Cart::getCategory,category);
//        wrapper.eq(SeatManage::getSeatState,state);
//        if (StrUtil.isNotBlank(search)) {
//            wrapper.like(SeatManage::getSeatNumber, search);
//        }else if(StrUtil.isNotBlank(cleanstate)){
//            wrapper.eq(SeatManage::getCleanstate,cleanstate);
//        }


        Page<Cart> Page = cartMapper.selectPage(new Page<>(pageNum, pageSize), wrapper);


        return Result.success(Page);
    }

    @PutMapping("/chucan") //put用来更新
    public Result<?> updatechucan(@RequestBody Cart cart) {

cart.setGoodsState("已出餐");
        cartMapper.updateById(cart);
        return Result.success();
    }

}
